<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import = "model.DanhmucModel" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content=content="text/html; charset=UTF-8">
<title>Quản Lý Sản Phẩm</title>
<link href="styles.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
    function validateForm() {
        var giaban = document.forms["myForm"]["giaban"].value;
        var kiemTraGB = isNaN(giaban);
        if (kiemTraGB == true) {
            alert("Giá bán phải để ở định dạng số");
            return false;
        }
        var soluong = document.forms["myForm"]["soluong"].value;
        var kiemTrasl = isNaN(soluong);
        if (kiemTrasl == true) {
            alert("Sô lượng phải để ở định dạng số");
            return false;
        }
        var discount = document.forms["myForm"]["discount"].value;
        var kiemTraDC = isNaN(discount);
        if (kiemTraDC == true) {
            alert("Discount phải để ở định dạng số");
            return false;
        }
    }
</script>
</head>
<body>
<jsp:include page="admin-header.jsp" />
<%
DanhmucModel model = new DanhmucModel();
String optionlist = model.getOptions(false, false,(String)(request.getAttribute("madanhmuc")));
%>

<form class="tknc" id="dm" accept-charset="ISO-8859-1" method = "post" action="quanlysanpham?option=edit" enctype="multipart/form-data" name="myForm" onsubmit="return validateForm()">
	<div class="login-header">
			<span>Sửa Sản Phẩm</span>
			<a href="#" class="close">x</a>
	</div>
	<div class="login-content">
	<label> Tên sản phẩm :</label>
	<input type = "text" name = "tensp" required value = ${listsp.get(0).getTensp() }><br>
	<label> Danh mục : </label>
	<select name = "MADANHMUC" required><%=optionlist%></select><br>
	<label> Mô tả: </label>
	<textarea name = "mota" rows="8" cols="60" required>${listsp.get(0).getMota()}</textarea><br>
	<label>Giá bán:</label>
	<input type = "text" name = "giaban" required value = ${listsp.get(0).getGiaban() }><br>
	<label>Thương hiệu :</label>
	<input type = "text" name = "thuonghieu" required value = ${listsp.get(0).getThuonghieu() }><br>
	<label>Số lượng :</label>
	<input type = "text" name = "soluong" required value = ${listsp.get(0).getSoluong() }><br>
	<label>Discount</label>
	<input type = "text" name = "discount" required value = ${listsp.get(0).getDiscount() }><br>
	<label>Hình ảnh mô tả 1:</label>
	<input type="file" name="uploadFile" / required>
	<label>Hình ảnh mô tả 2:</label>
	<input type="file" name="uploadFile1" / required>
	<label>Hình ảnh mô tả 3:</label>
	<input type="file" name="uploadFile2" / required>
	<input type = "hidden" name = "masp" value =${listsp.get(0).getMasp() } >
	<input type = "submit" value = "Save">
</form>
</body>
</html>